package cn.fly.springbucks.data.mybatis.mapper;

import cn.fly.springbucks.data.mybatis.model.Coffee;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.session.RowBounds;
import org.joda.money.Money;

@Mapper
public interface CoffeeMapper {
    @Select("select * from t_coffee order by id")
    List<Coffee> findAllWithRowBounds(RowBounds rowBounds);

    @Select("select * from t_coffee order by id")
    List<Coffee> findAllWithParam(@Param("pageNum") int pageNum,
                                  @Param("pageSize") int pageSize);

    @Select("select * from t_coffee where name = #{name} order by id")
    Coffee getCoffeeByName(@Param("name") String name);

    @Update("update t_coffee set price = #{price} where name = #{name}")
    int updatePriceByID(@Param("name") String name, @Param("price") Money price);

}